﻿using System.Collections.Generic;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using Twins.Infrastructure;
using Twins.Interface;
using Twins.Interface.IHandler;

namespace Twins.Classes.Hanlder.HanlderExpression
{
    public class HanlderForIAssignmentExpression : IHandler<IAssignmentExpression>
    {
        public IEnumerable<ILineCode> DoFor(IAssignmentExpression assignmentExpression)
        {
            var hashLineCode = assignmentExpression.OperatorSign.GetText();
            var receiveHashLineCodeFromProcesserCSharpExpression = IoC
                .Resolve<IReceiveHashLineCodeFromProcesserCSharpExpression>();
            receiveHashLineCodeFromProcesserCSharpExpression
                .ReceiveHashLineCode(assignmentExpression.Source, ref hashLineCode);
            return new List<ILineCode> { new LineCode(assignmentExpression, hashLineCode) };
        }

        public IEnumerable<ILineCode> DoFor(object obj)
        {
            return DoFor((IAssignmentExpression)obj);
        }
    }
}